#include <cstdio>
using namespace std;

#define ANS_LENGTH 40

int FindMax(int a, int b) { if (a > b) return a; else return b; }
int ProcessNumber(int[], int, int);
void PrintNumber(int[], int);

int main()
{
    int m, a, b;
    while (true) {
        scanf(" %d", &m);
        if (m == 0)
            break;
        scanf(" %d %d", &a, &b);

        int a_turned[ANS_LENGTH] {}, b_turned[ANS_LENGTH] {};
        int a_pos = ProcessNumber(a_turned, a, m);
        int b_pos = ProcessNumber(b_turned, b, m);

        // printf("a_pos = %d, b_pos = %d\n", a_pos, b_pos);
        // PrintNumber(a_turned, a_pos);
        // PrintNumber(b_turned, b_pos);

        int carry_old = 0, carry_new = 0, ans[ANS_LENGTH] = {0};
        int pos = FindMax(a_pos, b_pos);
        for (int i = 0; i < pos + 1; i++)
        {
            carry_old = carry_new;
            if (a_turned[i] + b_turned[i] + carry_old >= m)
                carry_new = 1;
            else
                carry_new = 0;
            ans[i] = (a_turned[i] + b_turned[i] + carry_old) % m;
        }

        // PrintNumber(ans, ANS_LENGTH);
        for (int i = pos - 1 + ans[pos]; i >= 0; i--)
            printf("%d", ans[i]);
        printf("\n");
    }

    return 0;
}

int ProcessNumber(int x[], int a, int scale)
{
    int pos = 0, origin = a;
    do {
        x[pos++] = origin % scale;
        origin /= scale;
    } while (origin != 0);

    return pos;
}

void PrintNumber(int x[], int pos)
{
    for (int i = pos - 1; i >= 0; i--)
        printf("%d", x[i]);
    printf("\n");
}